package cn.iocoder.yudao.module.erp.dal.mysql.suppliersendorderitem;

import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.erp.controller.admin.suppliersendorderitem.vo.SupplierSendOrderItemPageReqVO;
import cn.iocoder.yudao.module.erp.controller.admin.suppliersendorderitem.vo.SupplierSendOrderItemSaveReqVO;
import cn.iocoder.yudao.module.erp.dal.dataobject.suppliersendorderitem.SupplierSendOrderItemDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * ERP 随货同行单项 Mapper
 *
 */
@Mapper
public interface SupplierSendOrderItemMapper extends BaseMapperX<SupplierSendOrderItemDO> {

    default PageResult<SupplierSendOrderItemDO> selectPage(SupplierSendOrderItemPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<SupplierSendOrderItemDO>()
                .eqIfPresent(SupplierSendOrderItemDO::getOutOrderId, reqVO.getOutOrderId())
                .eqIfPresent(SupplierSendOrderItemDO::getProductId, reqVO.getProductId())
                .eqIfPresent(SupplierSendOrderItemDO::getProductUnit, reqVO.getProductUnit())
                .eqIfPresent(SupplierSendOrderItemDO::getProductStandards, reqVO.getProductStandards())
                .eqIfPresent(SupplierSendOrderItemDO::getProductPrice, reqVO.getProductPrice())
                .eqIfPresent(SupplierSendOrderItemDO::getBatch, reqVO.getBatch())
                .betweenIfPresent(SupplierSendOrderItemDO::getValidityDate, reqVO.getValidityDate())
                .eqIfPresent(SupplierSendOrderItemDO::getCount, reqVO.getCount())
                .eqIfPresent(SupplierSendOrderItemDO::getTotalPrice, reqVO.getTotalPrice())
                .eqIfPresent(SupplierSendOrderItemDO::getRemark, reqVO.getRemark())
                .betweenIfPresent(SupplierSendOrderItemDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(SupplierSendOrderItemDO::getId));
    }
    default PageResult<SupplierSendOrderItemDO> selectPage(PageParam reqVO, String outOrderId) {
        return selectPage(reqVO, new LambdaQueryWrapperX<SupplierSendOrderItemDO>()
                .eq(SupplierSendOrderItemDO::getOutOrderId, outOrderId)
                .orderByDesc(SupplierSendOrderItemDO::getId));
    }

    default int deleteByOutOrderId(String outOrderId) {
        return delete(SupplierSendOrderItemDO::getOutOrderId, outOrderId);
    }

    default List<SupplierSendOrderItemDO> selectListByOutOrderId(String outOrderId){
        return selectList(SupplierSendOrderItemDO::getOutOrderId, outOrderId);
    }

    default List<SupplierSendOrderItemDO> selectListByOutOrderIds(List<String> outOrderIds){
        return selectList(SupplierSendOrderItemDO::getOutOrderId, outOrderIds);
    }

    default int deleteByOutOrderId(Long outOrderId){
        return delete(SupplierSendOrderItemDO::getOutOrderId, outOrderId);
    }

    void updateSupplierSendOrderItems(List<SupplierSendOrderItemSaveReqVO> list);
}